tywx.ShareInterface = {
    OnShareAppMessageInfo: null,
    setOnShareAppMessageInfo: function(e, t, a, n) {
        this.OnShareAppMessageInfo = {
            title: e,
            imageUrl: t,
            sharePointId: a,
            shareSchemeId: n
        };
    },
    getOnShareAppMessageInfo: function() {
        return this.OnShareAppMessageInfo;
    },
    getRandomOnShareAppMessageInfo: function() {
        var e = [];
        for (var t in tywx.PropagateInterface._cachedShareConfig) e.push(t);
        if (e && e.length > 0) {
            var a = Math.floor(1e4 * Math.random()) % e.length, n = e[a], r = tywx.PropagateInterface._cachedShareConfig[n];
            if (r && r.length > 0) return {
                title: r[a = Math.floor(1e4 * Math.random()) % r.length].shareContent,
                imageUrl: r[a].sharePicUrl,
                sharePointId: r[a].sharePointId,
                shareSchemeId: r[a].shareSchemeId
            };
        }
        return null;
    },
    getRandomShareInfo: function(e) {
        try {
            var t = tywx.PropagateInterface._cachedShareConfig[e];
            if (t && t.length > 0) {
                var a = Math.floor(1e4 * Math.random()) % t.length;
                return {
                    title: t[a].shareContent,
                    imageUrl: t[a].sharePicUrl,
                    sharePointId: t[a].sharePointId,
                    shareSchemeId: t[a].shareSchemeId
                };
            }
        } catch (e) {}
        return null;
    },
    share: function(e, t, a, n, r, i, c) {
        tywx.IsWechatPlatform() && (tywx.BiLog.clickStat(tywx.clickStatEventType.clickStatEventTypeUserShare, [ a, 1, n ]), 
        wx.shareAppMessage({
            title: e,
            imageUrl: t,
            query: "inviteCode=" + tywx.UserInfo.userId + "&sourceCode=" + a + "&inviteName=" + tywx.UserInfo.userName + "&imageType=" + n + "&extraInfo=" + (c || ""),
            success: function(e) {
                r && r(e), tywx.BiLog.clickStat(tywx.clickStatEventType.clickStatEventTypeUserShare, [ a, 2, n ]);
            },
            fail: function(e) {
                i && i(e);
            },
            complete: function() {}
        }));
    }
}, tywx.onShareAppMessageInit = function(e) {
    if (tywx.IsWechatPlatform()) {
        var t = "inviteCode=" + tywx.UserInfo.userId + "&sourceCode=" + config.sharePointId + "&inviteName=" + tywx.UserInfo.userName + "&imageType=" + config.shareSchemeId;
        e && "" != e && (t = t + "&" + e), wx.onShareAppMessage(function(e) {
            var a = tywx.ShareInterface.getOnShareAppMessageInfo();
            return null == a && (a = tywx.ShareInterface.getRandomOnShareAppMessageInfo()), 
            tywx.BiLog.clickStat(tywx.clickStatEventType.clickStatEventTypeUserShare, [ a.sharePointId, 1, a.shareSchemeId ]), 
            {
                title: a.title,
                imageUrl: a.imageUrl,
                query: t,
                success: function(e, t) {
                    tywx.BiLog.clickStat(tywx.clickStatEventType.clickStatEventTypeUserShare, [ a.sharePointId, 2, a.shareSchemeId ]);
                },
                fail: function() {},
                complete: function() {}
            };
        });
    }
};